package com.blacktry.mapper.blog;

import com.blacktry.entity.blog.Sorts;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blacktry.entity.model.vueVO.Option;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author blackTry
 * @since 2022-02-07
 */
public interface SortsMapper extends BaseMapper<Sorts> {

    @Select("select sorts.sort_id as value,sorts.sort_name as label from sorts")
    List<Option> selectSortOptions();

    @Select("select sorts.sort_name as label,sorts.sort_id as value from article_sort,sorts where article_sort.article_id = #{id} and article_sort.sort_id = sorts.sort_id")
    List<Option> selectOneSortOptions(String id);

    @Select("select sorts.sort_id from article_sort,sorts where article_sort.article_id = #{id} and article_sort.sort_id = sorts.sort_id")
    String[] backOneSortOptions(String id);
}
